<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>个人资料</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
	<link rel="stylesheet" th:href="@{/css/public.css}" media="all" />
</head>
<body class="childrenBody">
<form action="" method="post" class="layui-form layui-row" lay-filter="dataFrm" id="dataFrm">
	<div class="layui-col-md6 layui-col-xs12">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">用户名</label>
			</div>
			<div class="layui-inline">
				<span id="username"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">职位</label>
			</div>
			<div class="layui-inline">
				<span id="position"/>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">姓名</label>
			</div>
			<div class="layui-inline">
				<span id="name"/>
			</div>
		</div>
		<div class="layui-form-item" pane="">
			<label class="layui-form-label">性别</label>
			<div class="layui-input-block userSex">
				<input type="radio" name="sex" value="1" title="男" checked="">
				<input type="radio" name="sex" value="0" title="女">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">手机号码</label>
			<div class="layui-input-block">
				<input type="tel" name="phone" value="" placeholder="请输入手机号码" lay-verify="phone" class="layui-input userPhone">
			</div>
		</div>
		<div class="layui-form-item userAddress">
			<div class="layui-inline">
				<label class="layui-form-label">所属城市</label>
			</div>
			<div class="layui-inline">
				<span id="c_name"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">身份证</label>
			<div class="layui-input-block">
				<input type="text" name="identity" value="" placeholder="请输入身份证号" lay-verify="required|identity" class="layui-input userEmail">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="changeUser">提交</button>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript">
	var form, $;
	layui.use(['form','layer'],function(){
		form = layui.form;
		$ = layui.jquery;
		var layer = parent.layer === undefined ? layui.layer : top.layer;

		$.ajax({
			url: "/admin/user/loadUser",
			type: "get",
			dateType: "json",
			success: function (json) {
				form.val("dataFrm",json.data);
				$('#username').html(json.data.username);
				$('#position').html(json.data.position);
				$('#c_name').html(json.data.c_name);
				$('#name').html(json.data.name);
			}
		});

		//提交个人资料
		form.on("submit(changeUser)",function(data){
			$.post("/admin/user/changeUser", data.field, function (res){
				layer.msg(res.msg);
			})
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		})
	})
</script>
</body>
</html>